| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | "use strict"; |
||
| 52 | function parseConfig(configStr) { |
||
| 53 | var config = {}; |
||
| 54 | var lines = configStr.split('\r\n'); // Split lines |
||
| 55 | var lastCellLine = lines[0].split(' '); // Save first line |
||
| 56 | var mowers_lines = lines.splice(1, lines.length-1); // Array of mowers |
||
| 57 | config.topRightPos = {x:parseInt(lastCellLine[0]), y:parseInt(lastCellLine[1])}; // Define first line in config object |
||
| 58 | config.mowers = []; |
||
| 59 | for(var i=0; i<mowers_lines.length; i++) { |
||
| 60 | if(i%2){ |
||
| 61 | var position = mowers_lines[i-1].split(' '); |
||
| 62 | config.mowers.push({ |
||
| 63 | pos:{x:parseInt(position[0]), y:parseInt(position[1])}, |
||
| 64 | cardinal:position[2], |
||
| 65 | instructions:mowers_lines[i].split('') |
||
| 66 | }); |
||
| 67 | } |
||
| 68 | } |
||
| 69 | return config; |
||
| 70 | } |